﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using System.Web.Security;

namespace Medianamik.Core.Logging
{
    public class DatabaseTarget : Target
    {
        protected override void Write(LogEventInfo logEvent)
        {
            if (logEvent.Parameters.Length == 6)
            {
                var objectId = logEvent.Parameters[0] as Guid?;
                var objectName = logEvent.Parameters[1] as string;
                var userName = logEvent.Parameters[2] as string;
                var type = (LogEntryType)logEvent.Parameters[3];
                var IP = logEvent.Parameters[4] as string;
                var UserAgent = logEvent.Parameters[5] as string;

                DALProviderManager.DALProvider.ConfigDALProvider.LogActivity(objectId, objectName, userName, logEvent.Message, IP, UserAgent, type);
            }
        }
    }
}
